﻿@using OBUCare.Web.Infrastructure;
@using OBUCare.Core.Models;
@using OBUCare.Core.BL
@using OBUCare.Core.DataAccess;
@using OBUCare.Core.Common;
@{
    ViewBag.Title = "StockIn";

    var operatorInfo = UIUtility.GetCurrentUser();

    var menuName = PageData["moduleID"] == null ? UIUtility.getMenuName(Request.RawUrl) : PageData["moduleID"];
    ViewData["menuName"] = menuName;
}
<link href="../../Content/tableCss.css" rel="stylesheet" type="text/css" />
<table width="100%">
    <tr>
        <td style="text-align: center">
            <span style="font-weight: bold; font-size: 16px">元器件销售信息查询</span>
        </td>
    </tr>
    <tr>
        <td>
            @Html.Partial("_PartsSaleSearch")
        </td>
    </tr>
    <tr>
        <td>
            @(Html.Telerik().Grid<View_PARTS_SALE>()
            .Name("Grid")
            .DataKeys(keys => keys.Add(c => c.ID))
            .Sortable(sorting => sorting.SortMode(GridSortMode.SingleColumn))
            .Resizable(resizing => resizing.Columns(false))
            .DataBinding(dataBinding => dataBinding
                .Ajax().Select("ListPartsSale", "PartsReport", new { sql = "" })
                )
            .Columns(columns =>
            {
                columns.Bound(o => o.PARTS_NAME).Width("8%");
                columns.Bound(o => o.OBU_NO).Width("12%");
                columns.Bound(o => o.VEHICLE_PLATE_NO).Width("10%");
                columns.Bound(o => o.USER_NAME).Width("20%");
                columns.Bound(o => o.OBU_REGISTE_DATE).Format("{0:yyyy-MM-dd}").Width("10%");
                columns.Bound(o => o.AMOUNT).Width("6%");
                columns.Bound(o => o.REPORT_DATE).Width("10%");
                columns.Bound(o => o.AGENT_NAME).Width("10%");
                columns.Bound(o => o.OPERATOR_NAME).Width("10%");
            })
            .ClientEvents(events =>
                {
                    events.OnError("onError");
                    events.OnDataBinding("onDataBinding");
                })
            .TableHtmlAttributes(new { style = "width:150%" })
                                   .Scrollable(scroll => scroll.Height(CommonStyleForUI.Grid_Height))
                                   .Footer(true)
                                             .Pageable(paging =>
                                             {
                                                 paging.Style(CommonStyleForUI.Grid_PageStyle)
                                                 .Position(CommonStyleForUI.Grid_PagePosition)
                                                 .PageTo(CommonStyleForUI.Grid_CurrentPage)
                                                 .PageSize(CommonStyleForUI.Grid_PageSize, new int[] { 10, 20, 50, 100, 200, 500 });
                                             })
                            )
        </td>
    </tr>
</table>
<script language="javascript" type="text/javascript">

    function onError(e) {
        //debugger;
        e.preventDefault();
        /*if (e.XMLHttpRequest.status == "505")
        alert("系统字段不允许删除");
        else if (e.XMLHttpRequest.status == "506")
        alert("系统表不允许删除");
        else*/
        alert(e.XMLHttpRequest.getResponseHeader("message"));
    }


    function onDataBinding(e) {
        var grid = $('#Grid').data('tGrid')
        index = (grid.currentPage - 1) * grid.pageSize;
        e.data = {
            // the key ("category") specifies the variable name of the action method which will contain the specified value
            searchSql: $('#searchSql').val(),
            agentNO: $('#agentNO').val()
            , menuNames: $('#menuNames').val()
        };
    }
        
</script>
